#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

int n, m;
ll dp[2][1 << 6][1 << 6];
bool check(int u, int v) {
  int t = u & (u << 1);
  if ((u ^ t) & (v << 2)) return false;
  t = u & (u >> 1);
  if ((u ^ t) & (v >> 2)) return false;
  return true;
}
bool check2(int u, int v, int w) {
  int t = u & v;
  if ((u ^ t) & (w >> 1)) return false;
  if ((u ^ t) & (w << 1)) return false;
  return true;
}
bool check(int u, int v, int w) {
  if (!check(u, v) || !check(v, u) || !check(v, w) || !check(w, v))
    return false;
  if (!check2(u, v, w) || !check2(w, v, u)) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  int mx = (1 << m) - 1;
  rep(s, 0, mx) dp[1][0][s] = 1;
  rep(i, 2, n + 2) {
    int now = i % 2;
    int pre = (i - 1) % 2;
    rep(v, 0, mx) rep(w, 0, mx) dp[now][v][w] = 0;
    rep(u, 0, mx) {
      rep(v, 0, mx) {
        rep(w, 0, mx) {
          if (!check(u, v, w)) continue;
          dp[now][v][w] = (dp[now][v][w] + dp[pre][u][v]) % MOD;
        }
      }
    }
  }
  cout << dp[(n + 2) % 2][0][0];
  return 0;
}